package leetcode_day._2021._202107._0110;

import java.util.Arrays;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/7/4 17:58
 * 错误的集合
 * 算法：排序
 */
public class _04_645 {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(new _04_645().findErrorNums(new int[]{3, 2, 3, 4, 5, 6})));
    }

    public int[] findErrorNums(int[] nums) {
        int[] a = new int[nums.length + 1];
        for (int num : nums) ++a[num];
        int[] ans = new int[2];
        for (int i = 1; i < a.length; i++) {
            if (a[i] == 2) ans[0] = i;
            if (a[i] == 0) ans[1] = i;
        }
        return ans;
    }

}
